package com.huazi.www.frontdesk.servlet;

import com.alibaba.fastjson.JSON;
import com.huazi.www.frontdesk.service.impl.FrontdeskCardServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 补办
 */
public class FrontdeskreplacementServlet extends HttpServlet {
    FrontdeskCardServiceImpl frontdeskCardService = new FrontdeskCardServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8"); //修改request域的编码集
        resp.setContentType("text/thml;charse=UTF-8"); //修改respones域的编码集
        resp.setCharacterEncoding("UTF-8");//修改respones域的编码集
        PrintWriter out = resp.getWriter();//创建输出对象
        Integer id = Integer.parseInt(req.getParameter("ids"));//获取传过来的值 ids并转换为int类型
        String password = req.getParameter("pwd");//获取传过来的值pwd
        String idCard = req.getParameter("idCard");//获取传过来的值idCard
        String name = req.getParameter("name");//获取传过来的值name
        String sex = req.getParameter("sex");//获取传过来的值sex
        String phone = req.getParameter("phone");//获取传过来的值phone
        Integer age = Integer.parseInt(req.getParameter("age"));//获取传过来的值age
        Double money = Double.parseDouble(req.getParameter("moneys"));//获取传过来的值moneys
        boolean frontdeskcardupdate = frontdeskCardService.frontdeskcardupdate(id, password, idCard, name, sex, phone, age, money);//new frontdeskCardService类frontdeskcardupdate方法
        String isfrontdeskcardupdate = JSON.toJSONString(frontdeskcardupdate);//转JSON
        out.println(isfrontdeskcardupdate);//输出到页面
        out.flush();//清空缓存区
        out.close();//关闭缓存区
    }
}
